﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms.Design;

namespace Citrix.WorkflowStudio.Activities.WFSDatabaseActivities.TypeEditors
{
    [Serializable]
    class SQLColumnTypeEditor :  System.Drawing.Design.UITypeEditor
	{
        private List<Classes.SQLColumn> pSQLColumns = null;

        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            //IWindowsFormsEditorService editorService;

            //if (context == null || context.Instance == null || provider == null)
              //  return value;

           // try
            //{
                //editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                pSQLColumns = (List<Classes.SQLColumn>)value;
                PropertyEditorUI.SQLColumnEditor columnEditor = new Citrix.WorkflowStudio.Activities.WFSDatabaseActivities.PropertyEditorUI.SQLColumnEditor(pSQLColumns);
                columnEditor.ShowDialog();
                //return the value of the updated columns list.
                value = columnEditor.Columns;
                return base.EditValue(context, provider, value);
            //}
            //finally
            //{
              //  editorService = null;
            //}
        }
        public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            //if (context != null && context.Instance != null)
            //{
                return System.Drawing.Design.UITypeEditorEditStyle.Modal;
            //}
            //return base.GetEditStyle(context);
        }
 
	}
}
